﻿package net.wangit.jdbc.table;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.wangit.jdbc.database.Database;

public abstract class Constraint {
	private String name;
	private final List<Column> columns = new ArrayList<Column>();

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void addColumn(Column column) {
		if (!(this.columns.contains(column)))
			this.columns.add(column);
	}

	public void addColumns(Iterator<Column> columns) {
		while (columns.hasNext())
			addColumn((Column) columns.next());
	}

	public int getColumnSpan() {
		return this.columns.size();
	}

	public abstract String sqlConstraintString(Database paramDatabase);

	public List<Column> getColumns() {
		return this.columns;
	}
}